﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SlimDX;

namespace Blake.Fluid
{
    public class Particle
    {
        public Vector3 Position;
        public Color3 Color;
        public int Next;
        public Vector3 Velocity;
        public Vector3 VelocityEvaluative;
        public Vector3 Acceleration;
        public ushort Age;
        public bool IsFixed;

        public void IntegratePosition(float DeltaTime)
        {
            //Leapfrog integration
            var velocityNext = Acceleration * DeltaTime;

            // v(t+1/2) = v(t-1/2) + a(t) dt
            velocityNext += Velocity;

            VelocityEvaluative = Velocity;
            VelocityEvaluative += velocityNext;

            // v(t+1) = [v(t-1/2) + v(t+1/2)] * 0.5		used to compute forces later
            VelocityEvaluative *= 0.5f;

            Velocity = velocityNext;
        }
    }
}
